export const namespace = "stadiumClassroom";
import { weekNameList } from "@/pages/course/interface";
import { Tag } from "antd";
import dayjs from "dayjs";
import { history } from "umi";
export const courseTypeList = { 1: "私", 2: "团", 3: "班", 4: "占" };
const courseTypeNameList = { 1: "私教课", 2: "团课", 3: "班课", 4: "其他占用" };
export const calcColumns = (params) => {
  const { operate, venueArr, labelArr } = params;
  // let enumlist = {};
  // venueArr.forEach((v) => {
  //   enumlist[v.id] = {
  //     text: v.venueName,
  //   };
  // });
  // let roomFacilityNames = {};
  // labelArr.forEach((v) => {
  //   roomFacilityNames[v.id] = v.facilityName;
  // });
  const columns = [
    {
      title: "教室名称",
      dataIndex: "classRoomName",
      // width: 300,
      render: (_, record) => (
        <a
          onClick={() => {
            history.push(`/stadium/classroom/details/${record.id}`);
          }}
        >
          {record.classRoomName}
        </a>
      ),
    },
    {
      title: "可容纳人数",
      dataIndex: "containPeopleNum",
      hideInSearch: true,
    },
    // {
    //   dataIndex: "venueId",
    //   title: "所属场馆",
    //   valueEnum: enumlist,
    // },
  ];
  if (operate && operate.length > 0) {
    operate.map((item) => {
      columns.push(item);
    });
  }
  return columns;
};
export const calcColumns2 = (params) => {
  const columns = [
    {
      title: "占用时间",
      dataIndex: "startTimeSlot",
      width: 300,
      render: (_, record) => (
        <span>
          {dayjs(record.startTimeSlot).format("YYYY-MM-DD")}(
          {
            weekNameList[
              dayjs(record.startTimeSlot).day() == 0
                ? 7
                : dayjs(record.startTimeSlot).day()
            ]
          }
          ) {dayjs(record.startTimeSlot).format("HH:mm")} ~
          {dayjs(record.endTimeSlot).format("HH:mm")}
        </span>
      ),
    },
    {
      title: "类型",
      dataIndex: "occupiedType",
      width: 150,
      render: (_, record) => (
        <div>
          <Tag>{courseTypeList[record.occupiedType]}</Tag>
          {courseTypeNameList[record.occupiedType]}
        </div>
      ),
    },
    {
      title: "状态",
      dataIndex: "status",
      width: 150,
      valueEnum: {
        1: { text: "已占用", status: "Processing" },
        2: { text: "已完成", status: "Success" },
      },
    },
    {
      title: "占用原因",
      dataIndex: "remark",
      ellipsis: true,
    },
  ];
  if (params?.operate) {
    columns.push(params?.operate);
  }
  return columns;
};
